package handlers

import (
	"github.com/gin-gonic/gin"
	"strconv"
	"weibo-sys/modle"
)

func ArticleList(c *gin.Context) {
	page, _ := strconv.Atoi(c.Query("page"))
	size, _ := strconv.Atoi(c.Query("size"))
	offset := (page - 1) * size

	var articleList []modle.Article
	modle.DB.Debug().Limit(size).Offset(offset).Find(&articleList)

	var total int64
	modle.DB.Model(&modle.Article{}).Count(&total)
	c.JSON(200, gin.H{
		"code":  200,
		"msg":   "ok",
		"data":  articleList,
		"count": total,
	})
	return
}

func ArticleDetail(c *gin.Context) {

}
